package com.wd.live.module_login.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.tencent.mm.opensdk.utils.Log
import com.wd.live.module_base.ui.base.BaseResult
import com.wd.base.bean.LabelsBean
import com.wd.live.module_base.net.bean.login.LoginBean
import com.wd.live.module_base.net.util.HttpUtils
import com.wd.live.module_base.net.util.HttpUtils2
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import retrofit2.http.Field
import java.nio.charset.StandardCharsets

/**
 * 作者: 王晶晶
 * 时间:2024/5/22
 * 描述:
 */
class LoginViewModel:ViewModel() {
    //原生普通登录登录
    val dataLogin=MutableLiveData<BaseResult<LoginBean>>()
    fun postLogin(map:Map<String,String>){
        viewModelScope.launch(Dispatchers.IO){
            var result= HttpUtils2.apiService.postLogin(map)
            if (result.status=="0000"){
                dataLogin.postValue(result)
            }

        }
    }

//    //微信登录
//    val dataWXLogin=MutableLiveData<BaseResult<LoginBean>>()
//    fun postWXLogin(code:String){
//
////        Log.i("TAGggggg",""+postData.toString())
//        viewModelScope.launch (Dispatchers.IO){
//            var result=HttpUtils.apiService.postWXLogin(code)
//            if (result.status=="0000"){
//                dataWXLogin.postValue(result)
//            }
//        }
//    }
    //例
    val data = MutableLiveData<BaseResult<List<LabelsBean>>>()
    fun getLabelsData() {
        viewModelScope.launch(Dispatchers.IO) {
            var  result = HttpUtils.apiService.getLabels(840, "1716368698176840")
            if (result.status =="0000"){
                data.postValue(result)
            }

        }
    }

}